package com.xxx.corejava.day1016;

import java.math.BigDecimal;

public class Test1 {

    public static void main(String[] args) {

        /*
            java内部没有byte，short
            当作int来处理
            为了c++程序员方便
            用byte，short不能提高性能
            也不能节省空间
         */
        byte b1=1;//int->byte

        byte b2=(byte)(b1+b1);//强制类型转换 int转换成byte

        int i=128;
        System.out.println("i = " + i);

        byte b4= (byte) i;
        System.out.println("b4 = " + b4);

//        int i1=2100000000;

       int min=0x80000000;

       System.out.println("min = " + min);

       int max=0x7fffffff;

        System.out.println("max = " + max);

        int i1=010;
        System.out.println("i1 = " + i1);

        long l1=1024*1024*1024*2;//int转换long 自动类型转换
        System.out.println("l1 = " + l1);

        long l2=1024L*1024*1024*2;
        System.out.println("l2 = " + l2);


        double d1=1;//int->double
        System.out.println("d1 = " + d1);

        float f1= (float) 1.2;//double->float
        float f2=1.2F;

        double d2=1.2;

        System.out.println("d2 = " + d2);

        System.out.println(12.345-12);
        System.out.println(2.6-2);

        BigDecimal bd1=new BigDecimal("12.345");
        BigDecimal bd2=new BigDecimal("12");
        System.out.println(bd1.subtract(bd2));


        char c1='a';
        System.out.println("c1 = " + c1);

        System.out.println(c1+1);
        System.out.println((char)(c1+1));

        //java内部char当作int来处理
        char c2=97;
        System.out.println("c2 = " + c2);

//        Random random=new Random();
//        int num= random.nextInt(10);//[0,10)之间的随机整数

        double num=Math.random();//[0,1)之间的随机小数 0~0.999999

        System.out.println("num = " + num);
        
        //产生[a,b]之间的随机整数
//        (int) (num*(b-a+1)))+a
        //[0,9]
        int n= (int) (num*10)+0;//0~9

        System.out.println("n = " + n);

        //[2,11]
        int n2=(int) (num*10)+2;

        //随机生产a-z之间的字符
        char c= (char)((int) (Math.random()*('z'-'a'+1))+'a');
        System.out.println("c = " + c);


        char c3='中';
        System.out.println("c3 = " + c3);

        char c4='\u4e2d';
        System.out.println("c4 = " + c4);

        boolean b=true;
        b=false;

            boolean bo1=7>6;

    }


}
